package moa.structure;


/**<p>
 * This class modelises a couple (customer, date of transaction) for a transaction (purchase of an item)
 * </p>
 */
public class Transaction 
{

	/**<p>the customer who mades the transaction
	 * </p>
	 */
	private int customer;
	
	/**<p>the date of the transaction
	 * </p>
	 */
	private int date;
	
//************************************************************************************
//Constructor of the class Transaction
//************************************************************************************
	
	/**<p>
	 * Creates a Transaction with the customer and the date given in parameter
	 * </p>
	 */
	public Transaction (int customer , int date)
	{
		this.customer = customer;
		this.date = date;
	}
	
//************************************************************************************
//Accessors of the class Transaction
//************************************************************************************

	public int getCustomer() 
	{
		return customer;
	}

	public void setCustomer(int customer) 
	{
		this.customer = customer;
	}
	
	public void setTransaction (int customer, int date)
	{
		this.customer = customer;
		this.date = date;
	}

	public int getDate() 
	{
		return date;
	}

	public void setDate(int date) 
	{
		this.date = date;
	}

//************************************************************************************
//Methods of the class Transaction
//************************************************************************************
	
	/**<p>
	 * @return true if and only if the two transactions have the same customer and the same date
	 * </p>
	 */
	public boolean equals(Object o)
	{
		return(getCustomer()==((Transaction)o).getCustomer() && getDate()==((Transaction)o).getDate());
	}
	
	
	public String toString ()
	{
		return ("("+customer+","+date+")");
	}
	
	public int hashCode ()
	{
		return toString().hashCode();
	}
}
